<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml"
      xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>400来电列表</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <!--插件样式-->
    <link href="/dist/plugins/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=39cd89cd">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style>
        .table > tbody > tr > td {
            line-height: 24px;
            max-height: 24px;
            overflow: hidden;
        }

        span.lineOne {
            line-height: 28px;
            height: 28px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .divCheck {
            height: 100%;
            margin-left: 5px;
            line-height: 25px;
        }

        .divCheck input {
            float: left;
            margin-top: 7px;
            margin-right: 5px;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .left {
            width: 170px;
            float: left;
        }

        .right {
            margin-left: 180px;
        }

        .templateStyle {
            border: 1px solid #ddd;
            padding: 0 10px;
        }

        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .lineOneNoMore {
            text-align: left;
        }

        .lineOneNoMore span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }
        .table{
            border:1px solid #cbcbcd;
        }

        .jiaobiao3 {
            position: relative;
        }

        .jiaobiao3 i {
            display: block;
            width: 6px;
            height: 6px;
            background: url("/dist/img/newLog3.png");
            position: absolute;
            top: 0px;
            right: 5px;
        }
    </style>
</head>
<body>
<section class="content" id="app">
    <div class="div-td-content-more"><i></i></div>
    <iframe id="ifExprot" style="width:0px;height:0px;display: none;" frameborder="0"></iframe>
    <div style="height: 25px;margin-bottom: 10px;">
        <input type="text" placeholder="请输入关键字" class="form-control pull-left input-sm"
               style="width: 180px;" v-model="searchParams.key">
        <div class="pull-left" style="width:120px;margin-left:10px;">
            <select v-model="searchParams.callType" class="form-control"
                    style="height:25px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;">
                <option v-for="(item,i) in typeList" v-bind:value="item.value">{{item.name}}
                </option>
            </select>
        </div>
        <div class="pull-left" style="width:120px;margin-left:10px;">
            <select v-model="searchParams.flag" class="form-control"
                    style="height:25px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;">
                <option v-for="(item,i) in flagList" v-bind:value="item.value">{{item.name}}
                </option>
            </select>
        </div>
        <button type="button" class="btn oaBtn btn-sm" style="margin-left: 10px;float: left;" @click="search">
            查询
        </button>
        <button type="button" class="btn oaBtn pull-right btn-sm" @click="callAddBtn('edit','1')">
            新增来电
        </button>
    </div>
    <div class="box-body no-padding iframeH3" id="scrollDiv">
        <table class="table table-hover  text-center table-striped">
            <thead>
            <tr>
                <th style="width: 17px;">序号</th>
                <th style="width: 25px">来电人</th>
                <th style="width: 30px">来电号码</th>
                <th style="width: 50px">来电时间</th>
                <th style="width: 20px">类别</th>
                <th style="width: 25px">接听人</th>
                <!--<th style="width: 35px">经销商</th>-->
                <th style="width: 100px">备注</th>
                <th style="width: 20px">状态</th>
                <th style="width: 20px">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="(item,i) in list">
                <td style="margin-right: 6px;">{{i+nowPage+1}}</td>
                <td>
                    <span style="color:#2a8cec;cursor: pointer;" @click="goDetail('look',i)">{{item.callerName}}</span>
                </td>
                <td>{{item.callerTel}}</td>
                <td>{{item.callDate}}</td>
                <td>{{item.callType}}</td>
                <td>{{item.registerName}}</td>
                <!--<td>{{item.dealers}}</td>-->
                <td><span class="lineOne">{{item.remark}}</span></td>
                <td>{{item.flag}}</td>
                <td>
                    <a href="javascript:void(0);" @click="goDetail('edit',i,'0')"
                       style="color:#2a8cec;cursor: pointer;text-align: center">分配
                    </a>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div class="oa-pager text-center" style="margin-top: 5px;">
        共
        <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
        <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
        <span class="oa-pager-button" id="first">首页</span>
        <span class="oa-pager-button" id="prev">上一页</span>
        <span class="oa-pager-button" id="next">下一页</span>
        <span class="oa-pager-button" id="last">尾页</span>
    </div>
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=558d0414"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<!--ztree组件所需js-->
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.exhide-3.5.js"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">
    $.wyui.page.getByPage_callback = function (data) {
        app.nowPage = ($.wyui.page.queryParams.requestPage - 1) * 30
        app.list = data;
        if (app.isCheckedAll) {
            for (var j = 0; j < app.list.length; j++) {
                app.selectIds.push(app.list[j].id)
            }
        }
    };
    $.wyui.page.getByPage_scroll_callback = function (list) {
        if (list.length < 30) {
            isLoad = false;
        } else {
            for (var i = 0; i < list.length; i++) {
                app.list.push(list[i]);
            }
            isLoad = true;
        };
    };
    function refresh() {
        $.wyui.page.getByPage();
    }
    var app = new Vue({
        el: '#app',
        data: {
            currentUser: getCurrentUser(),
            pageType: $.wyui.page.urlParams.pageType,
            typeList: [
                {name: '请选择类别', value: ''},
                {name: '报修', value: '报修'},
                {name: '咨询', value: '咨询'},
                {name: '投诉', value: '投诉'},
                {name: '询价', value: '询价'}
            ],
            flagList:[
                {name: '请选择状态', value: ''},
                {name: '已处理', value: '已处理'},
                {name: '处理中', value: '处理中'},
                {name: '作废', value: '作废'}

            ],
            list: [],
            nowPage: 0,
            searchParams: {
                key: '',
                callType:'',
                flag:''
            },
            isCheckedAll: false,
            isCheckNew: false
        },
        methods: {
            //删除来电记录
            removeById: function (id, i) {
                if (confirm('确认要删除吗？')) {
                    var that = this;
                    $.wyui.postMethod(urlConfig.call.removeById, {id: id}, function (result) {
                        that.list.splice(i, 1);
                        that.getCallList();
                    });
                }
            },
            //新增来电
            callAddBtn:function (type, isAdd) {
                $.dialog({
                    content: 'url:/page/callService/detail.html?pageType=' + type + "&isAdd=" + isAdd + "&day=" + new Date(),
                    title: '来电详情',
                    width: 904,
                    height: 525,
                    max: true,
                    min: true,
                    lock: true
                });
            },
            //跳转页  编辑和查看
            goDetail: function (type, i) {
                var that = this;
                var id = that.list[i].id;
                console.log(id)
                var condition = '?id=' + id;
                if (type != 'edit') {
                    condition += '&pageType=' + type;
//                    top.closeTabByPageId("CallDetail");
//                    top.addTabs({
//                        id: 'CallDetail',
//                        title: '来电详情',
//                        close: true,
//                        url: 'callService/detail.html' + condition
//                    });
                    $.dialog({
                        content: 'url:/page/callService/detail.html' + condition,
                        title: '来电详情',
                        width: 904,
                        height: 525,
                        max: true,
                        min: true,
                        lock: true
                    });
                }
                if (type == 'edit') {
                    condition += '&pageType=edit'+ "&isAdd=0";
//                    top.closeTabByPageId("CallDetail");
//                    top.addTabs({
//                        id: 'CallDetail',
//                        title: '来电详情',
//                        close: true,
//                        url: 'callService/detail.html' + condition + "&t=" + new Date()
//                    });
                    $.dialog({
                        content: 'url:/page/callService/detail.html' + condition + "&t=" + new Date(),
                        title: '来电详情',
                        width: 904,
                        height: 525,
                        max: true,
                        min: true,
                        lock: true
                    });
                }
            },
            //查询方法
            search: function () {
                $.wyui.page.queryParams.requestPage = 1;
                $.extend($.wyui.page.queryParams, this.searchParams);
                $.wyui.page.getByPage();
            },
            convertAuditFlagToName: function (item) {
                switch (Number(item.auditFlag)) {
                    case -1:
                        return "-";
                        break;
                    case 0:
                        return "待-"+item.currentAuditorName+"-审核";
                        break;
                    case 1:
                        return "已通过";
                        break;
                    case 2:
                        return "已驳回";
                        break;
                    default :
                        break;
                }
            },
            isArray: function (id) {
                var that = this;
                if ($.inArray(id, that.selectIds) > -1) {
                    // 如果已经包含了该id, 则去除(单选按钮由选中变为非选中状态)
                    return true;
                } else {
                    // 选中该checkbox
                    return false;
                }
            },
            isEnable: function (item) {
                return true;
            },
            checked: function (item) {
                var that = this;
                /*if(item.auditFlag != '-1') {
                 alert('非草稿状态不可勾选')
                 return
                 }*/
                if(item.informationIntegrity != '100%') {
                    alert('请先完善本条信息后才能提交')
                    return
                }
                if ($.inArray(item.id, that.selectIds) > -1) {
                    // 如果已经包含了该id, 则去除(单选按钮由选中变为非选中状态)
                    console.log(that.selectIds.length)
                    for (var i = 0; i < that.selectIds.length; i++) {
                        if (that.selectIds[i] == item.id) {
                            that.selectIds.splice(i, 1);
                            console.log(that.selectIds)
                            console.log(that.selectIds.join(','))
                        }
                    }
                } else {
                    // 选中该checkbox
                    that.selectIds.push(item.id)
                }
            },
            getCallList:function () {
                var that = this;
                $.wyui.postMethod(urlConfig.call.getCallList,
                    {key:that.searchParams.key,callType:that.searchParams.callType,flag:that.searchParams.flag},
                    function (data) {
                        that.list = data.records;
                        console.log(that.list)
                    });
            }
        },
        mounted: function () {
            var that = this;
            console.log(JSON.stringify(currentUser))
        }
    });
    $.wyui.page.dataUrl = server.ip + urlConfig.call.getCallList;
    $.wyui.page.queryParams.pageType = $.wyui.page.urlParams.pageType;
    $.extend($.wyui.page.queryParams, app.searchParams);
    $.wyui.page.getByPage_callback = function (records) {
        app.list = records;
        document.getElementById("scrollDiv").scrollTop = 0;
    };
    $.wyui.page.getByPage_scroll_callback = function (list) {
        if (list.length < 30) {
            isLoad = false;
        } else {
            for (var i = 0; i < list.length; i++) {
                app.list.push(list[i]);
            }
            isLoad = true;
        }
    };
</script>
<script>
    /************************滚动加载******************************/
    var divscroll = document.getElementById('scrollDiv');

    function divScroll() {
        var wholeHeight = divscroll.scrollHeight;
        var scrollTop = divscroll.scrollTop;
        var divHeight = divscroll.clientHeight;
        console.log(scrollTop + divHeight, wholeHeight)
        if (scrollTop + divHeight >= wholeHeight - 2) {
//            alert('滚动到底部了！');
            if (isLoad) {
                isLoad = false;
                setTimeout($.wyui.page.getByPage("scroll"), 1000);

            }

            //这里写动态加载的逻辑，比如Ajax请求后端返回下一个页面的内容
        }

    }

    divscroll.onscroll = divScroll;
</script>
</body>
</html>